<template>
	<view class="all">
		<view class="photo-box">
			<image @longpress="handlePhoto" :src="urls" mode="widthFix" class="photos"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				urls:''
			}
		},
		methods: {
			handlePhoto(){
				uni.showActionSheet({
				    itemList: ['下载图片'],
				    success: (res) => {
				        console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
						uni.showLoading({
							title:'保存中...',
							mask:true
						})
						uni.downloadFile({
						    url: this.urls, //仅为示例，并非真实的资源
						    success: (res) => {
						        var tempFilePath  = res.tempFilePath 
								uni.saveImageToPhotosAlbum({
									filePath:tempFilePath,
									success: () => {
										uni.showToast({
											title:'保存成功',
											duration:2000
										}),
										uni.hideLoading()
									},
									
								})
						    }
						});
				    },
				    fail: function (res) {
				        console.log(res.errMsg);
				    }
				});
			}
		},
		onLoad(e) {
			this.urls = e.urls
		}
	}
</script>

<style>
.all{
	background-color: #000000;
	width: 100%;
	height: 100%;
	position: fixed;
	display: flex;
	justify-content: center;
	padding-top: 150rpx;
}
.photos{
	width: 640rpx;
}

</style>
